package com.leo;

import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;

/**
 * @ClassName Main
 * @Description javafx mvc 写法
 * @Author wangss
 * @date 2020.11.25 16:18
 * @Version 1.0
 */
public class Main extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        final Model model = new Model();
        final View view = new View();

        AnimationTimer animation = new AnimationTimer() {

            @Override
            public void handle(long now) {
                model.update();
            }
        };

        final MouseController controller = new MouseController(model, animation, view);
        view.getScene().addEventHandler(MouseEvent.MOUSE_PRESSED, controller);
        view.getScene().addEventHandler(MouseEvent.MOUSE_RELEASED, controller);
    }
}
